<#assign ctx=request.contextPath />
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>注册</title>
    <!-- CSS文件 -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <!--layui-->
    <link href="layui/css/layer.css" rel="stylesheet">
    <link href="/layui/css/layui.css" rel="stylesheet">

<#-- mystyle -->
    <link href="css/register.css" rel="stylesheet">
</head>

<body>
<header>
    <div class="header_content">
        <span class="platformName">数众科技</span>
    </div>
</header>
<form class="layui-form layui-form-pane">
    <div class="mainContent">
        <div class="logoBox">
            <span class="platformRegister">用户信息修改</span>
        </div>
        <div class="list">
            <span><span class="xx">*</span>账号</span>
            <input type="text" name="username" value="${user.username}" disabled class="form-control" lay-verify="required"/>
        </div>
        <div class="list">
            <span><span class="xx">*</span>密码</span>
            <input type="text" name="password" value="${user.password}" class="form-control" lay-verify="required|pass"
                   placeholder="请填写6到12位密码"/>
        </div>
        <div class="list">
            <span><span class="xx">*</span>确认密码</span>
            <input type="text" name="password2" value="${user.password}" class="form-control" lay-verify="required|pass"
                   placeholder="请填写6到12位密码"/>
        </div>
        <div class="list">
            <span><span class="xx">*</span>昵称</span>
            <input type="text" name="nickName" value="${user.nickName}" class="form-control" lay-verify="required"/>
        </div>
        <input hidden name="id" value="${user.id}">
        <#--<div class="list">-->
            <#--<span><span class="xx">*</span>验证码</span>-->
            <#--<div class="password pd2">-->
                <#--<input type="text" name="checkCode" style="width: 200px;" placeholder="请输入验证码"/>-->
                <#--<img src="/getCheckCode" style="width: 120px; border-radius: 5px;"-->
                     <#--onclick="this.src='${ctx}/getCheckCode?'+Math.random()">-->
            <#--</div>-->
        <#--</div>-->
        <div class="list SubmitBtnBox">
            <span>&nbsp;</span>
            <button id="saveBtn" class="btn btn-w-m btn-primary" lay-submit lay-filter="formSave">提交</button>
            &nbsp;&nbsp;&nbsp;
            <a href="${ctx}/userList" class="btn btn-w-m btn-default">返回</a>
        </div>
    </div>
</form>
</body>
<script src="${ctx}/js/jquery.min.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var layer = layui.layer;
        form.on('submit(formSave)', function (data) {
            var obj = data.field;
            if (obj.password != obj.password2) {
                layer.msg("两次密码不一致", {icon: 5});
                return false;
            }
            $.ajax({
                url: '${ctx}/updateUser',
                type: "post",
                data: obj,
                success: function (res) {
                    if (res.status == 0) {
                        window.location.href = "${ctx}/userList";
                    } else {
                        layer.msg(res.msg, {icon: 5})
                    }

                }
            });
            return false;
        });
        //自定义验证规则
        form.verify({
            pass: [/(.+){6,12}$/, '密码必须6到12位']
        });
    })
</script>
</html>
